<template>
  <div>
    <el-backtop :right="100" :bottom="200" :visibility-height="10" />
    <!-- 搜索 -->
    <el-space wrap style="margin-bottom:10px">
      <el-input v-model="userId" placeholder="请输入用户ID" clearable style="width:200px"/>
      <el-button type="primary" @click="listData">查找</el-button>
    </el-space>
    <!-- 列表 -->
    <el-table :data="tableData" style="width: 85%" border>
      <el-table-column prop="id" label="地址ID" align="center" />
      <el-table-column prop="userId" label="用户ID" align="center" />
      <el-table-column prop="consignee" label="签收人" align="center" />
      <el-table-column prop="phone" label="手机号" align="center" />
      <el-table-column prop="province" label="省份" align="center" />
      <el-table-column prop="city" label="城市" align="center" />
      <el-table-column prop="county" label="区/县" align="center" />
      <el-table-column prop="address" label="详细地址" align="center" />
    </el-table>
    <!-- 分页 -->
    <dome v-bind="domes" @limits="limits" @pages="pages" />
  </div>
</template>
<script>
import {post} from "@/util/http";
import dome from "@/components/DomeAndTop.vue";
// import { Search, Edit } from "@element-plus/icons-vue";
import { ElMessage } from "element-plus";
export default {
  components:{
    dome
  },
  data() {
    return {
      userId: "", //搜索
      tableData: [], //列表
      dialogFormVisible: false, //布尔值
      // 分页
      domes: {
        limit: 10,
        page: 1,
        total: 10,
      },
    };
  },
  created() {
    this.listData();
  },
  methods: {
    listData(){
          let data = {
        _gp: "admin.address",
        _mt: "list",
        userId:this.userId,
        page: this.domes.page, //当前页码
        limit: this.domes.limit, //页码长度
      };
       post(data)
        .then((res) => {
          if (200 == res.data.errno) {
            this.tableData = res.data.data.items
            this.domes.total = res.data.data.total
          } else {
            ElMessage.warning(res.data.errmsg);
          }
        })
        .catch((err) => {
          ElMessage.error(err.data.errmsg);
        });
    },
    limits(e) {
      this.domes.limit = e;
      this.listData();
    },
    pages(e) {
      this.domes.page = e;
      this.listData();
    },

  },
};
</script>